<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
    <base href="<%=basePath %>">
    <title>采购退货</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <%-- 引用layui.css --%>
    <link rel="stylesheet" type="text/css" href="<%=basePath %>js/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath %>css/common.css"/>
</head>
<body>
<div class="ibox">
    <div class="ibox-content bodycss">
        <!-- 表单搜索 开始 -->
        <section class="panel panel-padding ">
            <form class="layui-form layui-form-pane form-search" onsubmit="return false" method="get">
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">商品名称</label>
                    <div class="layui-input-inline">
                        <input name="goodsName" id="goodsName" value="" placeholder="请输入商品名"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button class="layui-btn layui-btn-primary" lay-submit lay-filter="search">
                        <i class="layui-icon"></i> 搜 索
                    </button>
                </div>
            </form>
        </section>
        <!-- 表单搜索 结束 -->

        <div class="ibox-toolbar">
            <button id="confirm"
                    data-field="delete"
                    data-action=""
                    class="layui-btn layui-btn-sm layui-btn-danger">
                <i class="layui-icon">&#xe640;</i>采购商品退货
            </button>
        </div>

            <table class="layui-table"
                   lay-data="{
	                        id: 'mlsTableReload',
	                        width:'1228',
	                        url:'CGGL030/queryList.do',
	                        page:true,
	                        even:true,
	                        skin:'row',
	                        limits:[10,20,30,40,50],
	                        limit:10
	                        }"
                   lay-filter="popedomLay">
                <thead>
                <tr>
                    <th lay-data="{checkbox:true,disabledKey:'check_status',disabledKeyValue:'1,2'}"></th>
                    <th lay-data="{type:'numbers', width:50}">序号</th>
                    <th lay-data="{field:'purchaseId', width:200,align:'center'}">采购单号</th>
                    <th lay-data="{field:'goodsName', width:120, align:'center'}">商品名称</th>
                    <th lay-data="{field:'specifications', width:200,align:'center',templet:'#sl_name'}">规格</th>
                    <th lay-data="{field:'number', width:200,align:'center'}">采购数量</th>
                    <th lay-data="{field:'statu', width:200,align:'center',templet:'#m_type'}">状态</th>
                    <th lay-data="{field:'createTime', width:200,align:'center'}">创建时间</th>
                    <%--<th lay-data="{field:'channelId', width:200,align:'center'}">channelId</th>--%>
                </tr>
                </thead>

            </table>
        </section>
    </div>
</div>
<script type="text/html" id="m_type">
    {{#  if(d.statu =="0") {  }}
    <font color="#00ff00">未到货</font>
    {{#  } else if(d.statu =="2") {  }}
    <font color="#ff0000">申请退货</font>
    {{#  } else if(d.statu =="3") {  }}
    <font color="#ff0000">已退货</font>
    {{#  }  }}
</script>
<script type="text/javascript" src="<%=basePath %>js/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
        base: "<%=basePath%>js/common/"
    }).use(["common", "element", "layer", "form", "table", "jquery"], function () {
        var elem = layui.element;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        layui.common.init();
        // 确认按钮
        $("#confirm").on("click", function(){
            var s = table.checkStatus('mlsTableReload');
            if(s.data.length <= 0){
                layer.msg("请选择要退货的订单", {icon: 3,time: 2000});
                return;
            }
            if(s.data.length > 1){
                layer.msg("请选择一条要确认退货的订单", {icon: 3,time: 2000});
                return;
            }
            var sid = "";
            var id="";
            for(var i = 0; i < s.data.length;i++){
                sid += s.data[i].purchaseId;
                id += s.data[i].purchaseGoodsId;
            }
            layer.open({
                type: 2,
                title: '退货',
                content: "CGGL030/add.do?purchaseId="+sid+"&purchaseGoodsId="+id,
                area: ['500px', '350px'],
                anim: 5,
                isOutAnim: true,
                maxmin: true,
                resize: false,
                moveOut: true,
                zIndex: 99999,
                end : function(){
                    table.reload("mlsTableReload");
                }
        });
        });
        /**
         * 监听刷新表格
         */
        form.on('submit(search)', function (data) {
            /*console.log(JSON.stringify(data.field));*/
            table.reload('mlsTableReload', {
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });

    });
</script>
</body>
</html>
